/**
 * Created by dale on 2017/9/6.
 */
$(document).ready(function () {

    var form=new xhForm($('.xh-form'));


    var $depId=addressUri.getParam('iDepId');
    var $depName=addressUri.getParam('sDepName');
    $depName=unescape($depName);
    $(".form-date").datetimepicker({format: 'yyyy-mm-dd',language: 'zh-CN',minView: "month", autoclose:true});
    $(".form-month").datetimepicker({format: 'yyyy-mm',language: 'zh-CN',minView: "year", autoclose:true});
    $('#bt_modal_confirm',parent.document).addClass('disabled');

    form.parse().bindRequired($('#bt_modal_confirm',parent.document));
    if(staffInfo){
        // $.each(staffInfo, function(key, value){
        //     if(key!='sPrIcon'){
        //         var _dom = $('.xh-form').find('[name$='+ key +']');
        //         if(!_dom) return true;
        //         _dom.val(value);
        //     }
        // });
        delete staffInfo['sPrIcon'];
        // staffInfo.delete
        form.fill(staffInfo);
        $('[name=tBirthday]').trigger('change');
    }
    $('[name="iDepId"]').val($depId);
    $('[name="sDepName"]').val($depName);

    // setTimeout(function(){
    //     form.triggerRequired();
    // }, 500);

    $('#bt_modal_confirm',parent.document).click(function () {
        $('.xh-form').submit();
        window.top.xhTop.getActiveFrame().staffList.dataGridReload();
        window.top.xhTop.closeModal();
    });

    modalBind.bindClick();

});